<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>个税计算</title>
</head>
<body style="zoom:1.5;">
<table align="center">
    <tbody>
        <tr>
            <td align="right">工资:</td>
            <td><input type="text" id="A" value="30000"></td>
        </tr>
        <tr>
            <td align="right">五险一金:</td>
            <td><input type="text" id="B" value="4500"></td>
        </tr>
        <tr>
            <td align="right">申报:</td>
            <td><input type="text" id="C" value="2000"></td>
        </tr>
        <tr>
            <td align="right">起征点:</td>
            <td><input type="text" id="D" value="5000"></td>
        </tr>
        <tr>
            <th colspan="2">
                <button type="button" onclick="run()">开始计算</button>
            </th>
        </tr>
        <tr>
            <th colspan="2" id="result">

            </th>
        </tr>
    </tbody>
</table>
<script type="text/javascript">
function run(){
    var list = [];
    var A = document.getElementById('A').value;
    var B = document.getElementById('B').value;
    var C = document.getElementById('C').value;
    var D = document.getElementById('D').value;
    var E = A - B - C - D;
    for(var i = 1; i <= 12; i++){
        var F = E * i;
        var r = 0;
        var x = 0;
        if(F <= 36000){
            r = 0.03;
            x = 0;
        }
        else if(F > 36000 && F <= 144000){
            r = 0.1;
            x = 2520;
        }
        else if(F > 144000 && F <= 300000){
            r = 0.2;
            x = 16920;
        }
        else if(F > 300000 && F <= 420000){
            r = 0.25;
            x = 31920;
        }
        else if(F > 420000 && F <= 660000){
            r = 0.3;
            x = 52920;
        }
        else if(F > 660000 && F <= 960000){
            r = 0.35;
            x = 85920;
        }
        else if(F > 960000){
            r = 0.45;
            x = 181920;
        }
        if(i == 1){
            var sum = 0;
        }
        else{
            var sum = 0;
            for(var j = 1; j < i; j++){
                sum += list[j - 1];
            }
        }
        var G = F * r - x - sum;
        list.push(G);
    }
    var html = [];
    var all = 0;
    for(var k = 1; k <= list.length; k++){
        var current = list[k - 1];
        all += current;
        html.push(k + "月个税=" + current);
    }
    html.push("合计个税=" + all);
    html.push("到手收入=" + ((A - B) * 12 - all));
    document.getElementById('result').innerHTML = html.join("<br/>");
}
</script>
</body>
</html>
